package model;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;

import model.base.BaseServicerCompany;

@SuppressWarnings("serial")
public class ServicerCompany extends BaseServicerCompany<ServicerCompany> {
    public static final ServicerCompany dao = new ServicerCompany().dao();
    

	public ServicerCompany findFirstByServiserIdAndCompanyId(Long serviserId , Long companyId){
        return this.findFirst(" SELECT tsc.* FROM t_servicer_company tsc WHERE tsc.serviserId = ? AND tsc.companyId = ?  LIMIT 1 " , serviserId , companyId);
    }
	
	public void deleteByCompany(Company company) {
		Db.update(" DELETE FROM t_servicer_company WHERE companyId = ? " , company.getId() );
	}

	public List<Servicer> findByCompanyId(Long companyId){
        return Servicer.dao.find(" SELECT ts.* FROM t_servicer_company tsc LEFT JOIN t_servicer ts ON ts.id = tsc.serviserId WHERE tsc.companyId = ? " , companyId);
    }
}
